<?php
/**
 * Introduction: 用户第三方平台表  member_other_platform
 */

namespace Common\Model;


use Think\Model;

class MemberOtherPlatformModel extends Model
{
    //定义数据库连接信息
    protected $connection;

    //定义表名
    protected $tableName = 'member_other_platform';

    /**
     * 初始化
     */
    public function _initialize()
    {

        $this->connection = C('Databaese');

    }

    /**
     * 通过用户id,反查用户的weixin的openid
     * @param unknown $memberId
     */
    public function getWeixinOpenIdByMemberId($memberId)
    {
        $fields = ['data'];
        $record = $this->where("open_type=1 and userid=$memberId")->field($fields)->find();

        $jsonInfo = json_decode($record['data']);
        return $jsonInfo->openid?$jsonInfo->openid:0;
    }


}